/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.fpt.c0810g.newspj.model.checkvalidate;

/**
 *
 * @author anhgt_b00501
 */
public class CheckValidate {

    /**
     * @author:AnhGT
     * @param : control to validate
     * @return result is empty or not, = true is empty and = false is not empty
     */
    public boolean isEmpty(String control) {
        boolean result = false;
        if (control.length() == 0) {
            result = true;
        }
        return result;
    }

    /**
     * @author AnhGT
     * @param pLeghtRequiredMin do dai so sanh
     * @param str chuoi so sanh
     * @param kind loai so sanh <br> 1: == , 2: < , 3: >, 4: <= ,5: >=
     * @return Ket qua kiem tra
     */
    public boolean checkLeght(int pLeghtRequiredMin, String str, int kind) {
        boolean result = false;
        int lenght = str.length();

        //kiem tra loai
        if (kind == 0) {
            //kiem tra bang
            if (lenght == pLeghtRequiredMin) {
                result = true;
            }
        } else if (kind == 1) {
            //kiem tra nho hon
            if (lenght < pLeghtRequiredMin) {
                result = true;
            }
        } else if (kind == 2) {
            //kiem tra lon hon
            if (lenght > pLeghtRequiredMin) {
                result = true;
            }
        } else if (kind == 3) {
            //nho hon hoac bang
            if (lenght <= pLeghtRequiredMin) {
                result = true;
            }
        } else {
            if (lenght >= pLeghtRequiredMin) {
                result = true;
            }
        }
        return result;
    }
}
